package engine.newUi
{
	import engine.GameData;
	import engine.control.loading.MultLoader;
	import engine.data.BindManage;
	import engine.data.ModelLocator;
	import engine.data.Record;
	import engine.data.ResPath;
	import engine.display.Story.ActionControl.TimerTextField;
	import engine.event.CustomEvent;
	import engine.flag.ResourcesPath;
	import engine.net.event.CustomMsgEvent;
	import engine.net.messages.CustomToClientFlag;
	import engine.net.messages.CustomToServerFlag;
	import engine.net.messages.SystemMsgFlag;
	import engine.net.mgr.SystemSender;
	import engine.scene.SceneClickLogic;
	import engine.scene.SceneManager;
	import engine.scene.player.BasePlayerModel;
	import engine.tip.TipsMainLogic;
	import engine.ui.AlertUI;
	import engine.util.FilterUtil;
	
	import fl.motion.ColorMatrix;
	
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.events.TimerEvent;
	import flash.filters.BitmapFilterQuality;
	import flash.filters.ColorMatrixFilter;
	import flash.filters.GlowFilter;
	import flash.net.FileReferenceList;
	import flash.text.StaticText;
	import flash.text.TextFormat;
	import flash.ui.Mouse;
	import flash.utils.Timer;
	
	import newx.StageInfo;
	import newx.com.ResManager;
	import newx.com.config.StaticIni;
	import newx.com.control.HorizontalLayout;
	import newx.com.control.NxClip;
	import newx.com.control.button.NxButton;
	import newx.com.control.lite.NxButtonLite;
	import newx.com.control.text.NxLabel;
	import newx.com.control.text.NxText;
	import newx.com.control.window.NxWindowEvent;
	import newx.com.loader.SwfLoader;
	
	import org.osmf.events.TimeEvent;
	import org.osmf.proxies.ListenerProxyElement;
	
	import toolNet.Model;

	/**
	 * 禁地
	 * @author yangcg
	 * 
	 */	
	public class ForbiddenZoneLogic
	{
		public static var _self:ForbiddenZoneLogic
		public static function getInstance():ForbiddenZoneLogic
		{
			if(_self==null)
			{
				_self= new ForbiddenZoneLogic();
			}
			return _self ; 
		}
		public var _ui:ForbiddenZoneUI ; 
		private var _tips:TipsMainLogic;
		private var _model:ModelLocator;
		private var _bindManager:BindManage;
		private var _indexCountOne:int		= -1;
		private var _indexCountTwo:int		= -1;
		private var _indexCountThree:int 	= -1; 
		private var _indexCountFour:int 	= -1; 
		private var _indexCountFive:int 	= -1; 
		private var _indexCountSix:int 	= -1; 
		private var _indexCountSeven:int 	= -1; 
		private var _indexCountEight:int 	= -1; 
		private var _indexCountNine:int 	= -1; 
		
		private var _pageIndex:uint =1  ;
		/***多少副本**/
		private var _pageMax:uint ; 
		/**翻页当前章节**/
		private var _page:uint =1 ; 
		private var _FZlistID:Array=new Array(); 
		private var _listID:Object;
		private var _serverList:Array = new Array();
		private var _SceneMC:MovieClip;
		private var _pageCount:uint ; 
		private var _isOK:Boolean= true ;
		private var _pageNum:uint=1; 
		private var _tipsIsOK:Object; 
		private var _restCount:int ; 
		private var _arrTips:Array = new Array();
		private var ItemMC:MovieClip= new MovieClip();;
		private var _currentName:String;
		private var _ItemBtn:NxButton
		private var _glow:GlowFilter = new GlowFilter(0xfff292);
		private var _sceneClickLogic	:SceneClickLogic;
		private var _uiID:int =0 ; 
//		private var _page:MovieClip ; 
		/***初始化页签**/
		private var  _Initpage:Boolean=true;
		/**购买按钮 俩中Tips的切换**/
		private var _onGlow:Boolean; 
		/***翻页功能**/
		private var _setPage:int  =0 ; 
		/**总共章数***/
		private var _badgeCount:int =1 ;
		/**时间***/
		private var _date:Date = new Date();
		/****/
		private var _time:int ; 
		private var _timer:Timer ; 
		/**遮罩时间**/
		private var _maskTmier:Timer;  
		/***字幕**/
		private var infoTxt:TimerTextField	=new TimerTextField();
		/**字幕格式**/
		private var textFormat:TextFormat;
		/**重复字体不需要从新写一边**/
		private var _str:String  ="" ; 
		/**本章显示几个副本**/
		private var _showCount:int = 0 ;
		/***字体描边***/
		private var _golw:GlowFilter = new GlowFilter(0xffffff, 1, 6, 6, 3, BitmapFilterQuality.LOW);
		protected const COLOR_TABLE	:Array	=	["","#ffffff'>","#1eff00'>","#20BFF8'>","#a335ee'>","#E8912E'>","#e5cc80'>","#ffff00'>"];
		private var ld_Matrix:ColorMatrix=new ColorMatrix(); 
		private var ld_Filter:ColorMatrixFilter=new ColorMatrixFilter(); 
		
		
		/****/
		private var _xxxx:String   ="" ; 
		/**每一章的小章节****/
		private var _chapter:int  ;
		/**当前所点的副本*/
		private var _clickFor:MovieClip; 
		/***判断VIP的回复重置次数时间**/
		private var _restObj:Object ;
		/***服务器当前时间**/
		private var Systime:int; 
		public function ForbiddenZoneLogic()
		{
			
		}
		public function Init():void
		{
			ld_Matrix.SetBrightnessMatrix(-20);  
			ld_Filter.matrix = ld_Matrix.GetFlatArray(); 
			
			
			
			_ui =ForbiddenZoneUI.getInstance(); 
			_tips=TipsMainLogic.instance;
			_model = ModelLocator.getInstance();
			_bindManager= BindManage.getInstance();
			_model.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_FORBIDDEN_AREA_TIPS),getTipsInfo);
			_model.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_REQUEST_CHARGE) , getCountTips);
			_model.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_FORBID_COUNT_CHARGE) , setWindow);
			_model.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_SENDSERVERTIME),getSysDate);
			
			_timer = new Timer(1000); 
			_maskTmier = new Timer(50) ;
			
			
			
			
			textFormat					=	new TextFormat();
			textFormat.size				=	14;
			textFormat.bold				=	true
			textFormat.color			=	0x000000
//			textFormat.font="华文隶书";
//			textFormat.	 = 200; 
			
			infoTxt.wordWrap			=	true;
			infoTxt.mouseEnabled		=	false ; 		
			infoTxt.y					=	440;
			infoTxt.x					=	240;
			infoTxt.width				=	400;
			infoTxt.height				=	80;
			infoTxt.defaultTextFormat	=	textFormat;
			infoTxt.setTextFormat(textFormat);
			
			infoTxt.filters = [_golw] ; 
			_ui.label_22.buttonMode= true ; 
			_restObj = StaticIni.getIniObj("RecoveryTime");
		}
		private var masksp:Sprite; 
		private function addMask():void
		{
			masksp = new Sprite();
			masksp.graphics.beginFill(0xff0000);
			masksp.graphics.drawRect(0,0,500,100);
			masksp.graphics.endFill();
			masksp.x  =-150 ; 
			masksp.y  =470 ; 
			_ui.windowBG.addChild(masksp);
		}
		
		public function BeforeShow():void
		{
			
			//掉落图标
			_ui.awardTips.source = ResPath.PNG+"chakandiaoluo.png" ; 
			//掉落 提示字
			_ui.label_23.htmlText = StaticIni.getSwfLangStr("ForbiddenAreaStr_31");
			
			_ui.btncount.visible =false  ; 
			initSellGroup();
			MysterySellLogic.getInstance().SellType= 1; 
			MysterySellLogic.getInstance().BeforeShow(); 
//			_SceneMC=null;
//			_pageIndex =1 ; 
			_pageNum = 1; 
			var obj:Object = StaticIni.getIniObj("Chapter") as Object;
			_pageMax  = obj["Maxchapter"]; 
//			_badgeCount = getBadge(_pageMax) ; 
			_badgeCount = getBadge(_pageMax);
			addListener();
			initViewGroup(0);
			getPageIndex();
			visibleBtncount();
			bind();
			
			
		}
		private function addListener():void
		{
			_timer.addEventListener(TimerEvent.TIMER,timerHandler);
			_maskTmier.addEventListener(TimerEvent.TIMER,endMaskHandler);
			_ui.sellgroup.addItemsEvent(MouseEvent.MOUSE_OVER , overSellHandler);
			_ui.sellgroup.addItemsEvent(MouseEvent.MOUSE_OUT , outSellHandler);
			_ui.restSell.addEventListener(MouseEvent.CLICK,sellRestHandler); 
			_ui.sellgroup.addItemsEvent(MouseEvent.CLICK ,sellItemHandler);
			_ui.reset_btn.addEventListener(MouseEvent.CLICK,resetBtnHandler);
			_ui.right_btn.addEventListener(MouseEvent.CLICK,rightBtnHandler);
			_ui.left_btn.addEventListener(MouseEvent.CLICK,leftBtnHandler);
			_ui.sweep_btn.addEventListener(MouseEvent.CLICK,sweepBtnHandler);
			_ui.windowBG.addEventListener(NxWindowEvent.WINDOW_CLOSE,closeHandler);
//			_ui.btn_6.addEventListener(MouseEvent.CLICK ,sellHandler);
			_ui.btncount.addEventListener(MouseEvent.CLICK , sellCountHandler); 
			showTips(_ui.btncount);
			showTips(_ui.reset_btn);
			showTips(_ui.restSell);
			showTips(_ui.label_22);
			showTips(_ui.awardTips)
			showTips(_ui.label_23)
			
			_ui.itemGroup.addItemsEvent(MouseEvent.CLICK , itemGroupClickHandler);
			_ui.itemGroup.addItemsEvent(MouseEvent.ROLL_OVER , itemGroupOverHandler);
			_ui.itemGroup.addItemsEvent(MouseEvent.ROLL_OUT , itemGroupOutHandler);
		}
		/**
		* 关闭界面以后移除所有的监听事件
		* 
		*/		
		private function removeListener():void
		{
			_timer.removeEventListener(TimerEvent.TIMER,timerHandler);
			_ui.restSell.addEventListener(MouseEvent.CLICK,sellRestHandler); 
			_ui.reset_btn.removeEventListener(MouseEvent.CLICK,resetBtnHandler);
			_ui.right_btn.removeEventListener(MouseEvent.CLICK,rightBtnHandler);
			_ui.left_btn.removeEventListener(MouseEvent.CLICK,leftBtnHandler);
			_ui.sweep_btn.removeEventListener(MouseEvent.CLICK,sweepBtnHandler);
			
			_ui.windowBG.addEventListener(NxWindowEvent.WINDOW_CLOSE,closeHandler);
			MysterySellLogic.getInstance().removeEvent();
		}
		/**
		 *禁地商店按钮 
		 * @param Item
		 * 
		 */		
//		private function sellHandler(e:MouseEvent):void
//		{
//			_uiID   = 98 ; 
//			MysterySellLogic.getInstance().SellType= 1; 
//			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_REQUEST_OPEN_UI,_uiID ,1);
//			
//			
//			MysterySellUI.getInstance().showOrHide();
//			var _npcModel:MovieClip 
//			var doorConfig:String = "21000509";
//			var model:BasePlayerModel =	SceneManager.getInstance().getConfigMC(doorConfig);
//			_sceneClickLogic.sceneClick( GameData.Role, e.currentTarget as BasePlayerModel);
//			model.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_DOWN));
//		}
		/**
		 *	tips 显示 
		 * @return 
		 * 按钮
		 * 
		 */		
		private function showTips(Item:DisplayObject):void
		{
			Item.addEventListener(MouseEvent.MOUSE_OVER,overHandler);
			Item.addEventListener(MouseEvent.MOUSE_OUT,outHandler);
		}
		/**
		 * 
		 * @param e重置按钮 Tips显示
		 * 
		 */		
		private function overHandler(e:MouseEvent):void
		{
			var tip:String = ""; 
			if(e.currentTarget == _ui.reset_btn)
			{
				var obj:Object = StaticIni.getIniObj("ResetCount"); 
				var count:uint = int(obj["count"]);
				var max:int	   =  int(obj["max"]);
				
//				if(count==_restCount)
//				{
//					return  ; 
//				}
				if(_restCount>=max)
				{
					tip = StaticIni.getSwfLangStrVar("ForbiddenAreaStr_1",[_restCount, int(obj["count_max"])]);
////					
				}else 
				{
					var money:int  = int(obj["count_"+_restCount]);
					tip = StaticIni.getSwfLangStrVar("ForbiddenAreaStr_1",[_restCount,money]);
					
				}
			}else if (e.currentTarget == _ui.btncount)
			{
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_REQUEST_CHARGE,23);
			}else if (e.currentTarget==_ui.restSell)
			{
				tip = StaticIni.getSwfLangStr("ForbiddenAreaStr_28");
			}else if (e.currentTarget == _ui.label_22)
			{
				var arr:Array = (_restObj["vip"+_model.scene.Role.getVipLevel()] as String).split(",");
				tip = StaticIni.getSwfLangStrVar("ForbiddenAreaStr_29",[arr[1],arr[0]]);
			}else if(e.currentTarget == _ui.awardTips)
			{
				tip = StaticIni.getSwfLangStr(AwardTips) ; 
				TipsMainLogic.instance.isAutoSet	=	true;
			}else if (e.currentTarget == _ui.label_23)
			{
				tip = StaticIni.getSwfLangStr(AwardTips) ; 
				TipsMainLogic.instance.isAutoSet	=	true;

			}
				
			TipsMainLogic.instance.showString(tip);
		}
		private function outHandler(e:MouseEvent):void
		{
			TipsMainLogic.instance.hide();

			TipsMainLogic.instance.isAutoSet	=	false;
		}
		/**
		 * 监听事件函授
		 * 
		 */		
		private function closeHandler(e:NxWindowEvent):void
		{
			_ui.showOrHide();
		}
		//重置
		private function resetBtnHandler(e:MouseEvent):void
		{
			var obj:Object = StaticIni.getIniObj("ResetCount"); 
			var count:uint = int(obj["count"])
			var max:int = int(obj["max"])
			var money:int ;//int(obj["count_"+_restCount]);
			if(_restCount>=max)
			{
				 money = int(obj["count_max"]);
			}else
			{
				money = int(obj["count_"+_restCount]);
			}
			
			if(SitAlerUI.getInstance().created == false)
			{
				
				if(_model.scene.Role.getMagicCoin()<money)
				{
					NoticeUI.getInstance().showInfo(StaticIni.getSwfLangStr("UIStr_1001894"));
				}else
				{
					if(_restCount>=1)
					{
						AlertUI.showAlert("",StaticIni.getSwfLangStrVar("ForbiddenAreaStr_18",[money]),AlertUI.OK|AlertUI.CANCEL,restBtn);
//						SitAlerLogic.getIntatic().setUIinfo("ForbiddenAreaStr_18",[money],restBtn,_ui.reset_btn);
						
					}else
					{
						AlertUI.showAlert("",StaticIni.getSwfLangStr("ForbiddenAreaStr_17"),AlertUI.OK|AlertUI.CANCEL,restBtn);
//						SitAlerLogic.getIntatic().setUIinfo("ForbiddenAreaStr_17",[],restBtn,_ui.reset_btn);
					}
				}
				
			}
			
		}
		/**
		 * 禁地次数次数够买
		 * 
		 */	
		private function sellCountHandler(e:MouseEvent):void
		{
			AlertUI.showAlert("",StaticIni.getSwfLangStr("ForbiddenAreaStr_30"),AlertUI.OK|AlertUI.CANCEL,MeonyFun);
		}
		private function MeonyFun(type:int, str:String, clickData:*):void
		{
			if(AlertUI.OK == type )
			{
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_AFFIRM_CHARGE,23);
			}
			
		}
		private function restBtn(type:int, str:String, clickData:*):void
		{
			if(AlertUI.OK == type )
			{
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_AFFIRM_CHARGE,21,_chapter);
				
			}
		}
		//扫荡
		private function sweepBtnHandler(e:MouseEvent):void
		{
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_FORBIDDEN_AREA_SWEEP,_chapter);
		}
		public function get currTarget():int
		{
			return _chapter;
		}
		private function rightBtnHandler(e:MouseEvent):void
		{
			if(_badgeCount>_page)
			{
				_page++;
				if(_page>=_badgeCount)
				{
					_ui.right_btn.enabled = false ; 
				}
				initScene("Forbidden_"+(_page*5+1));
//				showInfo(_pageIndex);
				setViewGroupBtn(0); 
				initViewGroup(_page-1)
			}
			if(_page>1)
			{
				_ui.left_btn.enabled= true ;
			}
			
		}
		private function leftBtnHandler(e:MouseEvent):void
		{
			if(_page>1)
			{
				_page--;
				if(_page<=1)
				{
					_ui.left_btn.enabled = false ;
				}
				initScene("Forbidden_"+(_page*5+1));
//				showInfo("Forbidden_"+(_page*5+1));
				setViewGroupBtn(0); 
				initViewGroup(_page-1)
			}
			if(_page<_badgeCount)
			{
				_ui.right_btn.enabled= true ;
			}
		}
		/**
		 * 
		 * @param e 进入副本
		 * 
		 */		
		private function MCHandler(e:MouseEvent):void
		{
			var ItemMC:MovieClip = e.currentTarget as MovieClip ; 
			_clickFor=ItemMC
			if(ItemMC.buttonMode==true)
			{
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_ENTRY_FORBID_AREA,int(_listID[ItemMC.name][1]));
			}
			
		}
		private function getTipsFromMc(name:String):String
		{
			var tip:String;
			if(_SceneMC==null)return ""; 
			if(_SceneMC[name].data==1)
			{
				if(int(_listID[name][2]) == 1)
				{
					//没有开放此副本
					tip=StaticIni.getSwfLangStrVar("ForbiddenAreaStr_16",
						[
							StaticIni.getSwfLangStr(_listID[name][1].toString()),
							_listID[name][0],
							StaticIni.getSwfLangStr(_listID[name][2].toString())
						]);
				}else
				{
					if(int(_listID[name][2])==0)
					{
						tip=StaticIni.getSwfLangStrVar("ForbiddenAreaStr_19",
							[
								StaticIni.getSwfLangStr(_listID[name][1].toString()),
								_listID[name][0],
								StaticIni.getSwfLangStr(_listID[name][3].toString())
							]);
					}else
					{
						tip=StaticIni.getSwfLangStrVar("ForbiddenAreaStr_6",
							[
								StaticIni.getSwfLangStr(_listID[name][1].toString()),
								_listID[name][0],
								StaticIni.getSwfLangStr(_listID[name][2].toString()),
								StaticIni.getSwfLangStr(_listID[name][3].toString())
							]);
					}
					
				}
				
			}else
			{
				
				tip=StaticIni.getSwfLangStrVar("ForbiddenAreaStr_5",[StaticIni.getSwfLangStr(_listID[name][3].toString())]);
				
			}
			return tip;
		}
		/**
		 * 
		 * tips 
		 */
		private function overMCHandler(e:MouseEvent):void
		{
			ItemMC = e.target as MovieClip ; 
			_currentName=ItemMC.name;
			var tip:String ="" ; 
			var glow:GlowFilter = new GlowFilter(0xFFFFFF);
			if(ItemMC.buttonMode==true)
			{
				ItemMC.filters=[glow];
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_FORBIDDEN_AREA_TIPS,int(_listID[ItemMC.name][1]));
				
			}else
			{
				tip=getTipsFromMc(ItemMC.name);
			}
			TipsMainLogic.instance.showString( tip );
			
		}
		private function rollMCHandler(e:MouseEvent):void
		{
			TipsMainLogic.instance.hide();
			if(ItemMC.buttonMode==true)
			{
				ItemMC.filters=null;
			}
		}
		/**
		 * 
		 * 绑定列表
		 */
		private function bind():void
		{
			if(_indexCountOne==-1)
			{
				_indexCountOne =_bindManager.BindRecord(_model.scene,"PassedForbiddenArea",addItem,romoveItem);
			}
			if(_indexCountTwo==-1)
			{
				_indexCountTwo = _bindManager.BindProp(_model.scene.Role,"ForbiddenAreaResetCount",this , "getRestCount");
			}
			if(_indexCountThree==-1)
			{
				_indexCountThree =  _bindManager.BindProp(_model.scene.Role,"ForbiddenAreaEnterCount",this ,"getFBCount");
			}
			if(_indexCountFour==-1)
			{
				_indexCountFour=_bindManager.BindProp(_model.scene.Role,"ForbiddenAreaAddEnterCount",this ,"getSellCount");
			}
			if(_indexCountFive==-1)
			{
				_indexCountFive=_bindManager.BindProp(_model.scene.Role,"NextForbiddenAreaResetTime",this ,"getTimeRest");
			}
			if(_indexCountSix ==-1)
			{
				_indexCountSix=_bindManager.BindRecord(_model.scene,"VIPCountRec",addSllItem,romoveSellItem);
			}
			if(_indexCountSeven ==-1)
			{
				_indexCountSeven=_bindManager.BindProp(_model.scene.Role,"ForbiddenAreaResetedCount",this ,"getRestedCount");
			}
			if(_indexCountEight ==-1)
			{
				_indexCountEight=_bindManager.BindProp(_model.scene.Role,"Level",this ,"getLevel");
			}
			if(_indexCountNine == -1)
			{
				_indexCountNine=_bindManager.BindRecord(_model.scene,"ForbiddenRandomBoxRec",addBox,romoveBox);
			}
		}
		private function unbind():void
		{
			if(_indexCountOne!=-1)
			{
				_indexCountOne =_bindManager.UnbindRecord("PassedForbiddenArea",_indexCountOne);
			}
			if(_indexCountTwo!=-1)
			{
				_indexCountTwo = _bindManager.UnbindProp(_model.scene.Role,"ForbiddenAreaResetCount", _indexCountTwo);
			}
			if(_indexCountThree!=-1)
			{
				_indexCountThree =  _bindManager.UnbindProp(_model.scene.Role,"ForbiddenAreaEnterCount" ,_indexCountThree);
			}
			if(_indexCountFour!=-1)
			{
				_indexCountFour=_bindManager.UnbindProp(_model.scene.Role,"ForbiddenAreaAddEnterCount",_indexCountFour);
			}
			if(_indexCountFive!=-1)
			{
				_indexCountFive=_bindManager.UnbindProp(_model.scene.Role,"NextForbiddenAreaResetTime",_indexCountFive);
			}
			if(_indexCountSix!=-1)
			{
				_indexCountSix = _bindManager.UnbindRecord("VIPCountRec",_indexCountSix);
			}
			if(_indexCountSeven !=-1)
			{
				_indexCountSeven=_bindManager.UnbindProp(_model.scene.Role,"ForbiddenAreaResetedCount" ,_indexCountSeven);
				
			}
			if(_indexCountEight!=-1)
			{
				_indexCountEight=_bindManager.UnbindProp(_model.scene.Role,"Level",_indexCountEight);
			}
			if(_indexCountNine != -1)
			{
				_indexCountNine=_bindManager.UnbindRecord("ForbiddenRandomBoxRec",_indexCountNine);
			}
				
		}
		/**
		 * 
		 *绑定表格 加添和删除方法 
		 */		
		private function addItem(PropertiesName:String,PropertiesValue:Array,data:*):void
		{
			_serverList.splice(0);
			_serverList=completeFz
			updateList();
		}
		private function romoveItem(PropertiesName:String,PropertiesValue:Array,data:*):void
		{
			
		}
		/**
		 * 
		 * 当前章的数据
		 */		
		private function showInfo(value:String):void
		{
			_listID= new Object();
			var obj:Object = StaticIni.getIniObj(value);
			if(obj==null)return ; 
			_pageCount= obj["countChapter"]
			var i:uint = 1 ; 
			
			for( i ; i <=_pageCount ; i++)
			{
				var listStr:String = obj["mc_"+i] ;
				var arr:Array = new Array();
				arr  = listStr.split(",");
				_listID["mc_"+i]={};
				_listID["mc_"+i][0] = arr[0];
				_listID["mc_"+i][1] = arr[1];
				_listID["mc_"+i][2] = arr[2];
				
				
				_listID["mc_"+i][3] = arr[3];
			}
		}
		/**
		 * 判断要是否打过 这个副本
		 * 
		 */
		private function isCompare(value:int):Boolean
		{
			
			var j:uint = 0 ; 
			for(j;j<completeFz.length;j++)	
			{
				if(value==completeFz[j][0])
				{
					if(completeFz[j][2]==1)
					{
						return false ; 
					}else 
					{
						return true ; 
					}
					
				}
			}
			
			return false; 
		}
		/**
		 *  是否下一起副本
		 * @param value
		 * @return 
		 * 
		 */		
		private function isListCompare(value:int):Boolean
		{
			if(value==0)
			{
				return true ; 
			}
			var j:uint = 0 ; 
			for(j;j<completeFz.length;j++)	
			{
				if(value==completeFz[j][0])
				{
					return true ; 
					
				}
			}
			return false; 
		}
		/**
		 * 初始化当前本章的场景
		 * @return 
		 * 
		 */		
		//当前是哪个禁地 _Chapter == 禁地chapter ； 
		private var _Chapter:int  =0 ;  
		private function initScene(value:String):void
		{
			
			showInfo(value);
			if(_SceneMC!=null)
			{
				_ui.windowBG.removeChild(_SceneMC);
			}
			_ui.hintstorehouse.htmlText = "" ; 
			_Chapter = (StaticIni.getIniObj(value) as Object).chapter
			createScene(value);
		}
		/**
		 * 
		 * @param mc
		 * @param pl 章节名字~~~
		 * 
		 */
		private function setBtnLabel(value:uint):void
		{
//			_ui.btn_1.label = "暮色之村";
//			var i:uint = 1;  
//			for(i;i<=_pageCount;i++)
//			{
//				_ui["btn_"+i].label = StaticIni.getSwfLangStr(_listID["mc_"+i][1]);
//			}
//			_ui
		}
		private function createScene(value:String):void
		{
			//获取资源对象
			var mc:MovieClip= 	MultLoader.getInstance().getSourceByUrl(StageInfo.swfResPath+value+".swf")
			if(mc)
			{
				_SceneMC  = mc  ;
				_SceneMC.visible=true ; 
				_SceneMC.x = 190;
				_SceneMC.y=51;
				_ui.windowBG.addChild(_SceneMC);
				_ui.windowBG.addChild(_ui.reset_btn);
				_ui.windowBG.addChild(_ui.sweep_btn);
				_ui.windowBG.addChild(_ui.btncount);
				_ui.windowBG.addChild(_ui.fbcount);
				_ui.windowBG.addChild(_ui.sellgroup);
				_ui.windowBG.addChild(_ui.timelabel);
				_ui.windowBG.addChild(_ui.restSell);
				_ui.windowBG.addChild(infoTxt);
				_ui.windowBG.addChild(_ui.labe_restbtn) ; 
				_ui.windowBG.addChild(_ui.awardTips) ; 
				_ui.windowBG.addChild(_ui.label_23) ; 
				_ui.windowBG.addChild(_ui.hintstorehouse) ; 
				_ui.windowBG.addChild(_ui.hint) ; 


				var i :uint =1;
				for	(i;i<=_pageCount;i++)
				{
					_SceneMC["mc_"+i].gotoAndStop(1);
					_SceneMC["mc_"+i]["mc_"+i].filters = [_glow,FilterUtil.GrayColorFilter];
					_SceneMC["mc_"+i].buttonMode= false ; 
					_SceneMC["mc_"+i].addEventListener(MouseEvent.CLICK,MCHandler);
					_SceneMC["mc_"+i].addEventListener(MouseEvent.ROLL_OVER,overMCHandler);
					_SceneMC["mc_"+i].addEventListener(MouseEvent.ROLL_OUT,rollMCHandler);
					_SceneMC["mc_"+i].data=1;
					_SceneMC["mc_"+i]["box"].visible = false ; 
					/***按钮Tips**/
//					_ui["btn_"+i].data = 1;
//					_ui["btn_"+i].visible =true;  
//					_ui["btn_"+i].addEventListener(MouseEvent.ROLL_OVER,overBtnHandler);
//					_ui["btn_"+i].addEventListener(MouseEvent.ROLL_OUT,rollBtnMCHandler);
//					_ui["btn_"+i].addEventListener(MouseEvent.CLICK,fbBtnHandler);
//					(_ui["btn_"+i] as NxButton).data.HandleProperties("data","mc_"+i);
					
					
				}
				
//				bind();
				updateList();
				cowryFor();
			}else
			{
//				var j:uint =1 ; 
//				for	(j;j<=5;j++)
//				{
//					_ui["btn_"+j].visible =false ; 
//				}
				
				if(_SceneMC!=null)
				{
					_SceneMC.visible=false ; 
//					var count:int = _ui.windowBG.getChildIndex(_SceneMC);
//					if(count>0)
//					{
//						_ui.windowBG.removeChild(_SceneMC);
//					}
//					
				}
					
//				_SceneMC=mc ; 
					
//				if(_SceneMC!=null)
//					_ui.windowBG.re
//					_ui.windowBG.removeChildAt(1);
//					var i :uint =1;
//					for	(i;i<=5;i++)
//					{
//						_ui["btn_"+i].visible =false ; 
//					}
			}
			
		}
		/**
		 *哪个禁地有宝箱 
		 */	
		private function cowryFor(arr:Array = null ):void
		{
			if(arr==null)
			{
				var arr:Array = forbiddenRandomBoxRec ; 
			}
			var i:int =0 ; 
			for( i ; i <arr.length  ; i++)
			{
				if(_Chapter == arr[i][0])
				{
					for (var str:String in _listID)
					{
						var obj:Object = _listID[str] as Object
						if (obj == null )return  ; 
						if(obj[1] == arr[i][1])
						{
							 _SceneMC[str]["box"].visible = true ; 
							
							 _ui.hintstorehouse.htmlText ="<font size='18'>"+"<b>"+StaticIni.getSwfLangStrVar("ForbiddenAreaStr_33",
								 [
									 StaticIni.getSwfLangStr("Chapter_"+_Chapter) ,
									 StaticIni.getSwfLangStr(	StaticIni.getSwfLangStr(obj[1].toString())) 
								 ])+"</b>"+"</font>";  
							 _ui.hintstorehouse.x =  (_SceneMC.width - _ui.hintstorehouse.width)/2 +_SceneMC.x;
						}
					}
				}

			}
			
		}
		/**
		 *判断是否开启 和关闭关卡 
		 * 
		 */		
		private function updateList():void
		{
			/***扫荡按钮**/
			if(sweepOut())
			{
				_ui.sweep_btn.enabled=true;
			}else
			{
				_ui.sweep_btn.enabled=false;
			}
			/*****/
			_tipsIsOK = new Object();
			var i :uint =1;
			for	(i;i<=_pageCount;i++)
			{
				/***第一次副本一个也没有开*/
				if(completeFz.length==0)
				{
					if(i==1&&_listID["mc_1"][1]=="11380101")
					{
						_SceneMC["mc_"+i]["mc_"+i].filters = null ;
						_SceneMC["mc_"+i].buttonMode= true ; 
						_SceneMC["mc_"+i].data= 0;
						/**按钮*/
//						_ui["btn_"+i].buttonMode = true ; 
//						_ui["btn_"+i].enabled =true; 
					
						
					}
					else
					{
						_SceneMC["mc_"+i]["mc_"+i].filters = [_glow,FilterUtil.GrayColorFilter];
//						_SceneMC["mc_"+i].filters = [FilterUtil.GrayColorFilter1];
						_SceneMC["mc_"+i].buttonMode= false ; 
						_SceneMC["mc_"+i].data= 1;
						/***混掉的按钮*/
//						_ui["btn_"+i].buttonMode = false ;
//						_ui["btn_"+i].enabled =false; 
//						_ui["btn_"+i].mouseEnabled =true; 
//						_ui["btn_"+i].data = 1;
						
					}
					
				}else
				{
					
					if(isListCompare(_listID["mc_"+i][2])&&_model.scene.Role.getPlayerLevel()>=_listID["mc_"+i][0])
					{
						_SceneMC["mc_"+i].data= 0;
						if(isListCompare(_listID["mc_"+i][1]))
						{
							if(isCompare(_listID["mc_"+i][1]))
							{
								_SceneMC["mc_"+i]["mc_"+i].filters = null ;
								_SceneMC["mc_"+i].buttonMode= true ; 
//								/**开启按钮*/
//								_ui["btn_"+i].buttonMode = true ; 
//								_ui["btn_"+i].enabled =true; 
							}else
							{
								/**去掉灰掉建筑**/
								_SceneMC["mc_"+i]["mc_"+i].filters =[_glow,FilterUtil.GrayColorFilter];
								_SceneMC["mc_"+i].buttonMode= false ; 
								
								/***混掉的按钮*/
//								_ui["btn_"+i].buttonMode = false ;
//								_ui["btn_"+i].enabled =false; 
//								_ui["btn_"+i].mouseEnabled =true; 
							}
						}
						else
						{
							_SceneMC["mc_"+i]["mc_"+i].filters = null ;
							_SceneMC["mc_"+i].buttonMode= true ;
							/**按钮**/
//							_ui["btn_"+i].buttonMode = true ; 
//							_ui["btn_"+i].enabled =true; 
						}
						
					}else
					{
//						_ui["btn_"+i].buttonMode = false ;
//						_ui["btn_"+i].enabled =false; 
//						_ui["btn_"+i].mouseEnabled =true; 
					}
					//是否开启下一章
//					if(isListCompare(_listID["mc_"+i][1]))
//					{
//
//						//今天有没有打过
//						if(isCompare(_listID["mc_"+i][1]))
//						{
//							_SceneMC["mc_"+i].filters = null;
//							_SceneMC["mc_"+i].buttonMode= true ; 
//						}
//						else
//						{
//							_SceneMC["mc_"+i].filters = [FilterUtil.GrayColorFilter];
//							_SceneMC["mc_"+i].buttonMode= false ; 
//						}
//						
//						if(i+1>_pageCount)
//						{
//							
//						}else
//						{
//							if(_listID["mc_"+(i+1)][2]==1)
//							{
//								_SceneMC["mc_"+i].data= 0;
//								return ; 
//							}else
//							{
//								_SceneMC["mc_"+i].data= 0;
//								_SceneMC["mc_"+(i+1)].data= 0;
//								_SceneMC["mc_"+(i+1)].filters =null;
//								_SceneMC["mc_"+(i+1)].buttonMode= true ; 
//							}
//							
//						}
//						
//					}
				}
			}
		}
	
		/**
		 * 
		 * 
		 */		
		public function AfterHide():void
		{
			boxArr = [] ; 
			_Initpage =false ;
			unbind();
			removeListener();
			_ui.hintstorehouse.htmlText = "" ; 
		}
		/**
		 * 获取表 
		 * @return 
		 * 
		 */		
		public function get completeFz():Array
		{
			if(_model.scene.CheckProperties("PassedForbiddenArea"))
			{
				return (_model.scene.GetPropertiesEx("PassedForbiddenArea") as Record).recArr;
			}else 
			{
				return [];
			}
		}
		/**
		 * 当前通到第几关
		 */		
		private function getPageIndex():void
		{
			
			if(_Initpage==true)
			{
				var i:uint =1
				var pageCount:uint;
				for(i;i<_pageMax;i++)
				{
					showInfo("Forbidden_"+i);
					if(isListCompare(_listID["mc_"+_pageCount][1]))
					{
						_pageNum++;
						_pageIndex++;
						var _obj:Object = StaticIni.getIniObj("Forbidden_"+_pageIndex) ; 
						if(_model.scene.Role.getPlayerLevel()<_obj["Level"])
						{
							_pageIndex--;
						}
						if(_pageIndex>=_pageMax)
						{
							_pageIndex=_pageMax
						}
						if(_pageNum>=_pageMax)
						{
							_pageNum=_pageMax
						}
					}
				}
				initViewGroupBtn();
				_page  = getBadge(_pageIndex)
				initViewGroup(_page-1);
				
				initScene("Forbidden_"+_pageIndex);
				setViewGroupBtn(_pageIndex);
				//
				
				var obj:Object = StaticIni.getIniObj("Forbidden_"+_pageIndex) ; 
				 AwardTips=obj["awardTips"]
				startItem(obj["str"]);
				showLeftAndRight(_page);
			}else
			{
				var n:int = 1; 
				for	(n;n<=_pageCount;n++)
				{
					_SceneMC["mc_"+n]["box"].visible = false ; 
				}
				cowryFor() ;
//				bind();
			}
			_ui.name_label.htmlText = _page.toString(); 
		}
		/**
		 * 获取章节
		 */
		 private function getBadge(value:int):int
		 {
			 var count:int = value/5;
			 if(count==0)
			 {
				 return 1; 
				 
			 }else
			 {
				if(value%5!=0)
				{
					return count+=1; 
				}
				
			 }
			return -1 ; 
		 }
		/**
		 *  翻页显示按钮的方式
		 */		
		private function showLeftAndRight(value:uint):void
		{
			
			if(value<=1)
			{
				_ui.left_btn.enabled= false; 
				_ui.right_btn.enabled=false; 
			}else if(value>=_badgeCount)
			{
				_ui.left_btn.enabled= true; 
				_ui.right_btn.enabled=false;
			}else
			{
				_ui.left_btn.enabled= true; 
				_ui.right_btn.enabled=true;
			}
			
		}
		/**
		 * 重置次数 
		 */		
		public  function set getRestCount(value:int):void
		{
			var obj:Object = StaticIni.getIniObj("ResetCount"); 
			var count:int = int(obj["count"]) ;
			if(value>0)
			{
				_ui.reset_btn.enabled=true ;
				
			}else
			{
				_ui.reset_btn.enabled=false ;
			}
			_ui.label_22.htmlText = "禁地重置剩余:"+value.toString();
			
		}
		/**
		 * 第几次 重置禁地
		 */		
		public function set getRestedCount(value:int):void
		{
			_restCount = value+1;
			//每天的引导
			if(_restCount == 1)
			{
				_ui.hint.visible = true ;
			}else
			{
				_ui.hint.visible = false ;
			}
		}
		public function set getLevel(value:int):void
		{
//			setBtnPoint(value);
		}
		private function setBtnPoint(value:int,mc:MovieClip):void
		{
			if(_model.scene.Role.getPlayerLevel()<value)
			{
				mc["bnt1"].visible =true ; 
				mc["bnt2"].visible =false ; 
				mc["bnt1"].x  = 54
					
			}else
			{
				mc["bnt1"].visible =true ; 
				mc["bnt2"].visible =true ; 
				mc["bnt1"].x  = 11
			}
		}
		/**
		 *获取服务器给的Tips参数 
		 */		
		private function getTipsInfo(e:CustomMsgEvent):void
		{
			 
//			if(_SceneMC==null)return ; 
			_arrTips.splice(0);
			
			_arrTips = e.pList; 
			var tip:String=""
			if(int(e.pList[e.pList.length-1])==int(_listID[_currentName][1]))
			{
				if(_arrTips[0]==1)
				{
					tip = StaticIni.getSwfLangStrVar("ForbiddenAreaStr_3",
						[
							StaticIni.getSwfLangStr(_listID[_currentName][1].toString()),
							_arrTips[2],
							_arrTips[1],
							_arrTips[4],
							_arrTips[3],
							StaticIni.getSwfLangStr(_listID[_currentName][3].toString()),
						]);
				}else
				{
					tip = StaticIni.getSwfLangStrVar("ForbiddenAreaStr_12",
						[
							StaticIni.getSwfLangStr(_listID[_currentName][1].toString()),
							StaticIni.getSwfLangStr(_listID[_currentName][3].toString())
						]);
				}
			}
			TipsMainLogic.instance.showString( tip );
			
		}
		/**
		 * 
		 */	
		private function fbBtnHandler(e:MouseEvent):void
		{
			 var item:NxButton = e.target as NxButton;
			if(item.buttonMode==true)
			{
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_ENTRY_FORBID_AREA,int(_listID[item.name][1]));
			}
		}
		private function overBtnHandler(e:MouseEvent):void
		{
//			if(_SceneMC==null)return ; 
			var tip:String = "";
			var item:NxButton = e.target as NxButton;
			_currentName=item.data.GetProperties("data");
			if(item.buttonMode==true)
			{
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_FORBIDDEN_AREA_TIPS,int(_listID[item.name][1]));
				
			}else
			{
				tip=getTipsFromMc(item.data.GetProperties("data"));
//				if(isCompare(_listID[item.name][1])==false&&_listID[item.name][2]==0)
//				{
//					if(int(_listID[item.name][2]) == 1)
//					{
//						//没有开放此副本name=*{@0:本章内容}<br/>尚未开放，敬请期待！*
//						tip=StaticIni.getSwfLangStrVar("ForbiddenAreaStr_16",[StaticIni.getSwfLangStr(_listID[ItemMC.name][1].toString()),_listID[ItemMC.name][0],StaticIni.getSwfLangStr(_listID[ItemMC.name][2].toString())]);
//					}else
//					{
//						/***name=*{@0:本章内容}<br/>需要达到{@1:等级}级并通关{@2:副本}方能开启**/
//						tip=StaticIni.getSwfLangStrVar("ForbiddenAreaStr_6",[StaticIni.getSwfLangStr(_listID[ItemMC.name][1].toString()),_listID[ItemMC.name][0],StaticIni.getSwfLangStr(_listID[ItemMC.name][2].toString())]);
//					}
//					
//				}else
//				{
//					/**name=*已完成通关，需要重置后才可再次进入**/
//					tip=StaticIni.getSwfLangStr("ForbiddenAreaStr_5");
//					
//				}
			}
			TipsMainLogic.instance.showString( tip );
		}
		private function rollBtnMCHandler(e:MouseEvent):void
		{
			TipsMainLogic.instance.hide();
		}
		/**
		 * 
		 */		
		private function sweepOut():Boolean
		{
			for(var i:uint =1 ; i <=_pageCount;i++)
			{
				if(isCompare(_listID["mc_"+i][1]))
				{
					return true ; 
				}
			}
			return false ; 
		}
		/**
		 * 初始化ViewGroup  禁地副本
		 *  页签组件
		 * 
		 */		
		private function initViewGroup(value:int):void
		{
			var i :uint  =0 ; 
			for( i ; i<_ui.itemGroup.col*_ui.itemGroup.row ; i++)
			{
				var itemMC:MovieClip = _ui.itemGroup.getItemByIndex(i) ; 
				_showCount=_pageMax-value*5
//				itemMC.visible = true ;  
				var image:NxClip = new NxClip(); 
				itemMC["img"].addChild(image);
				itemMC["image"]=image;  
//				itemMC["bnt1"].gotoAndStop(1);
//				itemMC["bnt2"].gotoAndStop(1);
				if(i<_showCount)// _pageMax 
				{
					itemMC["isOK"] = true ; 
					itemMC["index"] = i+1; //(i+1)+(value*5)
					itemMC["SceseImage"] = "Forbidden_"+ (i+1) ; 
					var obj:Object = StaticIni.getIniObj("Forbidden_"+ (i+1+value*5));
					itemMC["elite"] = obj["elite"] ; 
					itemMC["Str"]  = obj["str"];
					itemMC["image"].source =ResPath.PNG + obj["image"]+".png" ; 
					
					itemMC["awardTips"] = obj["awardTips"]; 
					
					var obj_1:Object = StaticIni.getIniObj(obj["elite"]);
					setBtnPoint(obj_1["Level"],itemMC)
					
				}else
				{
					itemMC["isOK"] = false ; 
					itemMC["image"].source =ResPath.PNG +"BackImage_0"+".png" ; 
					itemMC["bnt1"].visible =false ; 
					itemMC["bnt2"].visible =false ; 
				}
//				
			}
		}
		/** 
		 * 初始化按钮状态
		 */		
		private function initViewGroupBtn():void
		{
			var i:int = 0 ; 
			for(i ; i<_ui.itemGroup.col*_ui.itemGroup.row ; i++)
			{
				var itemMC:MovieClip = _ui.itemGroup.getItemByIndex(i) ; 
				if(i<_showCount)
				{	itemMC.filters = [ld_Filter] ;
					itemMC["bnt1"].gotoAndStop(1);
					itemMC["bnt2"].gotoAndStop(1);
				}
			}
		}
		/**
		 * @param e 禁地商店
		 */
		private function initSellGroup():void
		{
			var i:uint =0 ; 
			for(i; i<_ui.sellgroup.col*_ui.sellgroup.row ;i++)
			{
				var _itemMC:MovieClip = _ui.sellgroup.getItemByIndex(i) ;
				(_itemMC["p_mc"] as MovieClip).gotoAndStop(1);
				var _img:NxClip= new NxClip();
				_img.x=_itemMC["img2"].x;
				_img.y=_itemMC["img2"].y;
				_itemMC["img"]=_img;
				_itemMC["txt"].text="";
				_itemMC["txt1"].text=""	;
				_itemMC["txt2"].text=""
				_itemMC["txt"].mouseEnabled=false;
				
				var _txtCount:NxLabel   =	new NxLabel();
				_txtCount.glowColor =0x081f22;
				_txtCount.x = _itemMC["img2"].x;
				_txtCount.y = _itemMC["img2"].y;
				_itemMC["txtCount"] = _txtCount;
				
				_itemMC.addChild(_img);
				_itemMC.addChild(_txtCount);
				_itemMC["dt_mc"].gotoAndStop(1);
			}
		}
		private var AwardTips:String  = "" ; 
		private function itemGroupClickHandler(e:MouseEvent):void
		{
			var itemMC:MovieClip = e.currentTarget as MovieClip ; 
			if(itemMC["isOK"]==false)
			{
				return ; 
			}
			
			
			initViewGroupBtn();
			itemMC.filters=[];
			itemMC["bnt1"].gotoAndStop(2); 
			startItem(itemMC["Str"])
			if(e.target ==itemMC["bnt1"])// 点击普通副本
			{	//
//				initViewGroupBtn();
				if(_xxxx == itemMC["SceseImage"])
				{
					return ; 
				}
				_xxxx = itemMC["SceseImage"]
					
				initScene(itemMC["SceseImage"]);
				_chapter = (StaticIni.getIniObj(itemMC["SceseImage"]) as Object).chapter;
				//显示本章的掉落tips
				AwardTips = itemMC["awardTips"] ;
				
				startItem(itemMC["Str"])
//			
			}else if(e.target ==itemMC["bnt2"])//点击英雄副本
			{
//				initViewGroupBtn();
				if(_xxxx == itemMC["elite"])
				{
					return ; 
				}
				_xxxx = itemMC["elite"]
				_chapter = (StaticIni.getIniObj(itemMC["elite"]) as Object).chapter;

				//显示本章的掉落tips
				AwardTips = (StaticIni.getIniObj(itemMC["elite"]) as Object).awardTips
					
				initScene(itemMC["elite"]);
				itemMC["bnt1"].gotoAndStop(1); 
				itemMC["bnt2"].gotoAndStop(2); 
				startItem(itemMC["Str"])
			}else
			{
				if(_xxxx == itemMC["SceseImage"])
				{
					return ; 
				}
				_chapter = (StaticIni.getIniObj(itemMC["SceseImage"]) as Object).chapter;
				
				AwardTips = (StaticIni.getIniObj(itemMC["SceseImage"]) as Object).awardTips;
				
				_xxxx = itemMC["SceseImage"]
				initScene(itemMC["SceseImage"]);
			}
			
		}
		/**
		 *爲什麽這樣處理 鼠標滑過去几个 
		 * @param e
		 * 
		 */		
		private function itemGroupOverHandler(e:Event):void
		{
			var itemMC:MovieClip = e.currentTarget as MovieClip ; 
			rollMC=itemMC;
		}
		/**
		 *为什么这样处理鼠标划过去就是一个 
		 */		
		private var _rollMc:MovieClip;
		private function set rollMC(value:MovieClip):void
		{
			if(_rollMc)
			{
				if(_rollMc.currentFrame !=3)
				{
					_rollMc.gotoAndStop(1);
				}
			}
			_rollMc=value;
			if(_rollMc)
			{
				if(_rollMc.currentFrame !=3)
				{
					_rollMc.gotoAndStop(2);
				}
			}
		}
		private function itemGroupOutHandler(e:Event):void
		{
			var itemMC:MovieClip = e.currentTarget as MovieClip ;
			rollMC=null;
		}
		/**
		 * 绑定禁地次数 
		 */		
		public function set getFBCount(value:int):void
		{
			if(value<0) {
				value  =0 ; 
			}
			_ui.fbcount.htmlText  =StaticIni.getSwfLangStrVar("UIString_1000575" , [value]) ; 
		}
		/**
		 * 添加禁地次数按钮的Tips  
		 */
		private function getCountTips(e:CustomMsgEvent):void
		{
			if(_ui.created==false )return  ;
			// 元宝
			if(_onGlow==true)
			{
				var str:String = StaticIni.getSwfLangStr("CapitalType_" + e.pList[0].toString());
				TipsMainLogic.instance.showString(StaticIni.getSwfLangStrVar("UIString_1000576",[e.pList[1]])) ; 
			}else
			{
				TipsMainLogic.instance.showString(StaticIni.getSwfLangStr("UIString_1000577")) ; 
			}
			
		}
		/**
		 *  购买次数按钮是否显示
		 */
		private function visibleBtncount():void
		{
			if(_model.scene.Role.getVipLevel()>=(StaticIni.getIniObj("sellCount") as Object).vipLevel)
			{
				_ui.btncount.visible =true ; 
			}
		}
		/**
		 *  购买次数
		 */	
		public  function set  getSellCount(value:int):void
		{
			
//			if((StaticIni.getIniObj("sellCount") as Object)["vip"+_model.scene.Role.getVipLevel()]<=value)
//			{
//				_ui.btncount.filters = [FilterUtil.GrayColorFilter];
//				_onGlow  = false ; 
//				
//			}else
//			{
				_ui.btncount.filters = [];
				_onGlow  = true ; 
//			}
		}
		/**timelabel
		 * 获取神秘商店 CD 时间
		 */
		public function set getTimeLabel(value:String):void
		{
			_ui.timelabel.htmlText = StaticIni.getSwfLangStrVar("ForbiddenAreaStr_22",[value]); 
//			_ui.label_23.htmlText = 
		}
		/**
		 * 购买物品按钮
		 */		
		private var _infoMC:MovieClip ; 
		private function sellItemHandler(e:MouseEvent):void
		{
			 _infoMC=e.currentTarget as MovieClip;
			if(e.target == _infoMC["btn"])
			{
				if(_model.scene.Role.getMagicCoin()<_infoMC["date"].price)
				{
					NoticeUI.getInstance().showInfo(StaticIni.getSwfLangStr("UIStr_1001894"));
				}else
				{
					if(SitAlerUI.getInstance().created == false)
					{
						
						SitAlerLogic.getIntatic().setUIinfo("ForbiddenAreaStr_26" ,[_infoMC["date"].price,link_color(StaticIni.getSwfLangStr(_infoMC["date"]["NameID"])+"x"+_infoMC["date"].amout,int(_infoMC["date"]["Color"]))],sendSellInfo, _infoMC.parent)
					}
				}
				
//				SystemSender.getInstance().CustomMsg(
//					CustomToServerFlag.CLIENT_CUSTOMMSG_BUY_MYSTERY_ITEM,int(MysterySellLogic.getInstance().SellType),_infoMC["PropertiesName"]);
			}
		}
		private function sendSellInfo():void
		{
			SystemSender.getInstance().CustomMsg(
								CustomToServerFlag.CLIENT_CUSTOMMSG_BUY_MYSTERY_ITEM,int(MysterySellLogic.getInstance().SellType),_infoMC["PropertiesName"]);
		}
		/**
		 * 刷新 购物 物品信息 
		 */		
		private function sellRestHandler(e:MouseEvent):void
		{
				if(_model.scene.Role.getMagicCoin()<200)
				{
					NoticeUI.getInstance().showInfo(StaticIni.getSwfLangStr("UIStr_1001894"));
				}else
				{
					
					if(SitAlerUI.getInstance().created == false)
					{
						SitAlerLogic.getIntatic().setUIinfo("ForbiddenAreaStr_27" ,[],RestSellInfo, _ui.restSell);
					}
				}
			
			
		}
		private function RestSellInfo():void
		{
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_AFFIRM_CHARGE,24);
		}
		/**
		 * 鼠标移到购买物品的TIPS
		 */		
		private function overSellHandler(e:MouseEvent):void
		{
			MysterySellLogic.getInstance().onOver(e);
		}
		/**
		 * 鼠标移到购买物品的移除TIPS 
		 */		
		private function outSellHandler(e:MouseEvent):void
		{
			MysterySellLogic.getInstance().onOut(e);
		}
		/**
		 * 服务器当前时间
		 */
		
		private function getSysDate(e:CustomMsgEvent):void
		{
			if(e.pList.length==0)return ; 
			
			Systime = e.pList[0];
			
			var date:Date = new Date(); 
			_date.time = (valueTimer*1000) - (Systime*1000);
			_timer.start();
			
		}
		/**
		 * 获取下一次物品刷新时间
		 */		
		private var valueTimer:int ; 
		public function set getTimeRest(value:int):void
		{
			Systime = 0 ;
			valueTimer= value;  
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_QUERYSERVERTIME);
			
		}
		/**
		 * 客户端倒计时
		 */		
		private function timerHandler(e:TimerEvent):void
		{
			if(_date.time>1000)
			{
				_date.time-=1000; 
				_ui.labe_restbtn.htmlText= StaticIni.getSwfLangStrVar("ForbiddenAreaStr_24",[initInfo(_date)]) ;
				
				if(_date.time<=0)
				{
					_timer.reset();
					_ui.labe_restbtn.htmlText =StaticIni.getSwfLangStrVar("ForbiddenAreaStr_24",["00:00:00"]) ;
				}
			}else
			{
				_timer.reset();
				_ui.labe_restbtn.htmlText =StaticIni.getSwfLangStrVar("ForbiddenAreaStr_24",["00:00:00"])
			}
		}
		/**
		 * 转换时间
		 */
		private function initInfo(date:Date):String
		{
			var str:String = ""
			var hours:int  = date.hoursUTC;
			var minutes:int  = date.minutesUTC;
			var seconds:int  = date.secondsUTC;
			
			str = initTime(hours)+":"+initTime(minutes)+":"+initTime(seconds) ; 
			return str
		}
		/**
		 * 时间处理
		 */		
		private function initTime(value:int):String
		{
			
			return (value>9?value:"0"+value).toString();
		}
		/**
		 *播放每一章的字幕~~~~哦 
		 */		
		private function startItem(value:String):void
		{	
			if(value ==_str)return  ; 
			_str = value ; 
			infoTxt.text =StaticIni.getSwfLangStr(value); 
		}
		private function endMaskHandler(e:TimerEvent):void
		{
			masksp.x += 5 ;
			if(masksp.x>360)
			{
				_maskTmier.reset();
			}
		}
		/**
		 * 手动设置 固定普通副本按钮 选中状态 
		 */		
		private function setViewGroupBtn(value:int):void
		{
			var itemMC:MovieClip = _ui.itemGroup.getItemByIndex(value-1) ; 
			var obj:Object = StaticIni.getIniObj("Forbidden_"+value) ;
			_chapter = obj["chapter"]
			itemMC.filters = [] ; 
			itemMC["bnt1"].gotoAndStop(2);
		}
		/**
		 * 
		 */		
		private function  addSllItem(PropertiesName:String,PropertiesValue:Array,data:* ):void
		{
			if(int(PropertiesValue[0]) == 41)
			{
				var value :int  = PropertiesValue[2]+PropertiesValue[3] -PropertiesValue[1] ;
				if(value<=0)
				{
					_ui.restSell.enabled=false ; 
				}else
				{
					_ui.restSell.enabled=true ; 
				}
				_ui.sellrestlabel.htmlText  =  StaticIni.getSwfLangStrVar("ForbiddenAreaStr_23",[value]) 
//				_ui.label_24.htmlText = StaticIni.getSwfLangStr("ForbiddenAreaStr_23");
			}
		}
		private function romoveSellItem(PropertiesName:String,PropertiesValue:Array,data:* ):void
		{
			
		}
		protected function link_color(str:String,color:int):String
		{
			if(color < 1 || color >8)
			{
				color	=	1;
			}
			return ("<font color ='"+COLOR_TABLE[color]+str+"</font>");
		}
		/**
		 *  提示购买禁地挑战次数
		 */	
		private function setWindow(e:CustomMsgEvent):void
		{
//			SitAlerLogic.getIntatic().setUIinfo(StaticIni.getSwfLangStr( "ForbiddenAreaStr_30" ),[], click,_clickFor,false);
//			function click():void
//			{
//				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_AFFIRM_CHARGE,23,int(_listID[_clickFor.name][1]));
//			}
			
			AlertUI.showAlert("",StaticIni.getSwfLangStr("ForbiddenAreaStr_30"),AlertUI.OK|AlertUI.CANCEL,click);
			
			function click(type:int, str:String, clickData:*):void
			{
				if(AlertUI.OK == type )
				{
					SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_AFFIRM_CHARGE,23,int(_listID[_clickFor.name][1]));
				}
				
			}
		}
		private var boxArr:Array = [] ; 
		private function addBox(PropertiesName:String,PropertiesValue:Array,data:* ):void
		{
			if(PropertiesValue.length == 0 )return ; 
			boxArr.push( PropertiesValue ); 
			cowryFor(boxArr) ;
		}
		private function romoveBox(PropertiesName:String,PropertiesValue:Array,data:* ):void
		{
			boxArr.splice(PropertiesName) ; 
			var i :uint =1;
			for	(i;i<=_pageCount;i++)
			{
				_SceneMC["mc_"+i]["box"].visible = false ; 
			}
			cowryFor() ;
		}
		/**
		 *  获取禁地 宝箱在那个禁地副本显示
		 */
		private function get forbiddenRandomBoxRec():Array
		{
			if(_model.scene.CheckProperties("ForbiddenRandomBoxRec"))
			{
				return (_model.scene.GetPropertiesEx("ForbiddenRandomBoxRec") as Record).recArr ;
			}else
			{
				return [] ; 
			}
		}
	}
}